#include <sys/types.h>
#include <sys/wait.h>
#include <iostream>
#include <signal.h>
#include <unistd.h>

using namespace std;

void Doanotherthing()
{
    cout << "Doanotherthing" << endl;
}

void handler(int signum)
{
    pid_t rid=waitpid(-1,nullptr,0);
    if(rid>0)
    {
        cout<<"wait success!"<<endl;
    }
    else
    {
        cout<<"wait false!"<<endl;
    }
}

int main()
{
    //signal(SIGCHLD,handler);
    signal(SIGCHLD,SIG_IGN);

    pid_t id = fork();
    if (id == 0)
    {
        // 子进程两秒后自动退出，给父进程发信号
        sleep(2);
        exit(-1);
    }

    //父进程可以做其他事情
    while (true)
    {
        Doanotherthing();
        sleep(1);
    }
    return 0;
}